home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #1 / Amiga Plus CD - 1997 - No. 01.iso / pd / programmierung / arexxport_dev / includes / rexx / arexxport.h
Encoding:
C/C++ Source or Header  |  1996-05-02  |  5.3 KB  |  164 lines

  1. #ifndef REXX_AREXXPORT_LIBRARY_H
  2. #define REXX_AREXXPORT_LIBRARY_H
  3.  
  4. /*************************************************************************/
  5. /*                    ArexxPort.library header file                      */
  6. /*                Andrew Cook     Copyright (c)1995-1996                 */
  7. /*                                                                       */
  8. /*           $ver: arexxport.library (header) 37.21 (02.5.96)            */
  9. /*************************************************************************/
  10.  
  11. #include <exec/types.h>
  12. #include <exec/lists.h>
  13. #include <exec/libraries.h>
  14. #include <utility/tagitem.h>
  15.  
  16. /*
  17. ** Some constants
  18. */
  19.  
  20. #define REXX_PORT_LEN   10
  21. #define REXX_MAX_ARGS   16
  22.  
  23. /*
  24. ** Macro to return the sigbit used by a
  25. ** given port.
  26. */
  27.  
  28. #define AREXX_SIGBIT( x )  (x)->Port->mp_SigBit
  29.  
  30. /*
  31. ** Macro that returns TRUE if a macro has been
  32. ** launched by the port and not yet returned.
  33. */
  34.  
  35. #define MACROPENDING( x ) ( (x)->Invocations.mlh_TailPred != (struct MinNode *)(&(x)->Invocations) )
  36.  
  37. /*
  38. ** Struct for list of arexx functions.
  39. ** Name is a pointer to the command name,
  40. ** Userdata is the value returned in the ArexxMsg structure.
  41. ** args is a standard AmigaDos arguement template. Used to parse
  42. ** the command line and values returned in the ArexxMsg again. The
  43. ** max number of arguements per command is REXX_MAX_ARGS (16). *   eg.
  44. **  const struct ArexxFunction[] = {
  45. **          {"Open", &MyOpen, "FILENAME"},         \* Your open command *\
  46. **          ...
  47. **          {NULL, NULL, NULL}                     \* Mark end of table *\
  48. **  };
  49. */
  50.  
  51. struct ArexxFunction {
  52.     STRPTR Name;
  53.     ULONG UserData;
  54.     STRPTR args;
  55. };
  56.  
  57. /*
  58. **   The ArexxPort Structure
  59. */
  60. struct ArexxPort {
  61.     /* These can be read and set */
  62.     ULONG                   User_Data;
  63.     BOOL                    Abort;
  64.  
  65.     /* Private - Read only */
  66.     char                    PortName[REXX_PORT_LEN + 10];
  67.     STRPTR                  Console,
  68.                             Extension;
  69.  
  70.     /* Private Data - Do not touch */
  71.     struct ArexxPort        *prev,
  72.                             *succ;
  73.     struct MsgPort          *Port;
  74.     struct MinList          Invocations;
  75.     struct ArexxFunction    *commandtable;
  76.     BOOL                    Debug;      /* This does nothing */
  77.     /* New For v37 - Read Only */
  78.     STRPTR                  LastError;
  79.     /* New For v37 - Private */
  80.     ULONG                   Flags;
  81. };
  82.  
  83.  
  84. /*
  85. ** The ArexxMsg Structure
  86. **
  87. ** This is returned by CheckPort() and freed by ReplyPort.
  88. ** All data is read only. The only interesting fields for
  89. ** Type, arg, User_Data, Port, Abort and msg.
  90. **
  91. ** Type = AREXX_COMMAND if message is the result of a command being
  92. ** recieved at the port. In that case the arg[] block contains the
  93. ** output of the line parsing. User_Data contains the user_data from the
  94. ** relevant ArexxFunction struct. Abort will be true if the Abort field of
  95. ** the port structure is true. NB this will go. Use amsg->port->Abort
  96. ** instead. msg field is a pointer to rexxmsg for this command. Use this
  97. ** oin SetRexxVar() and GetRexxVar() functions.
  98. **
  99. ** Type = AREXX_MESSAGE when the message is recieved is the return values of
  100. ** a command launched by this port. In which case, User_Data will have the
  101. ** data from the Invocation struct User_data in it.
  102. ** The first three arg[] will be filed as follows
  103. **   arg[0] = MacroName
  104. **
  105. **   There are four possible return states:
  106. **   Result1    Result2           Meaning
  107. **   -------    -------       ----------------
  108. **      0            0        Normal execution, no result requested.
  109. **                            arg[1] = NULL, arg[2] = NULL
  110. **      0           !=0       Normal execution, with result string.
  111. **                            arg[1] = "Returned this string", arg[2] = Result2
  112. **     !=0           0        Error.  Result1 is code from EXIT n.
  113. **                            arg[1] = "Returned with a %ld", rm_Result1, arg[2] = NULL
  114. **     !=0          !=0       Error.  Result2 is Arexx error code.
  115. **                            arg[1] = "Returned with error level %ld", result1
  116. **                            arg[2] = Arexx error text for that level, as returned
  117. **                            by ArexxFunction ErrorText()
  118. **
  119. */
  120.  
  121. struct ArexxMsg {
  122.     /* Private - Read only */
  123.     BOOL                Abort;      /* Redunant do not use. Use 'port->Abort' instead. */
  124.     UWORD               Type;
  125.     ULONG               arg[ REXX_MAX_ARGS ];
  126.     ULONG               User_Data;
  127.     struct ArexxPort    *port;
  128.     struct RexxMsg      *msg;
  129.  
  130.     /* Private - Do not touch */
  131.     struct RDArgs       *args;
  132.     STRPTR              storage;
  133. };
  134. #define AREXX_COMMAND   1
  135. #define AREXX_MESSAGE   2
  136.  
  137. /*
  138. **   List of macros lauched contains these
  139. **   structures and are read only. When macro returns then
  140. **   ArexxMsg User_Data is filled with User_Data.
  141. */
  142. struct ArexxInvocation {
  143.     struct MinNode  Node;
  144.     BOOL            console;
  145.     struct RexxMsg  *rexxmsg;
  146.     struct RexxMsg  *parent;
  147.     ULONG           User_Data;
  148. };
  149.  
  150. /*
  151. **   Tags for OpenArexxPort()
  152. */
  153. #define ARLT_NOINSTANCE        TAG_USER | 1L
  154. #define ARLT_COMMANDS          TAG_USER | 2L
  155. #define ARLT_CONSOLE           TAG_USER | 3L
  156. #define ARLT_CHAIN             TAG_USER | 4L
  157. #define ARLT_EXTENSION         TAG_USER | 5L
  158. #define ARLT_USER              TAG_USER | 6L
  159. #define ARLT_LASTERROR         TAG_USER | 7L
  160.  
  161. #endif  /* REXX_AREXXPORT_LIBRARY_H */
  162.  
  163.  
  164.